package server

import (
	"6-17yk/common/model/mysql"
	"6-17yk/common/proto/user"
	"errors"
)

func DoctorList(req *user.DoctorListReq) (*user.DoctorListResp, error) {
	list, err := mysql.DoctorList()
	if err != nil {
		return nil, errors.New("查询失败")
	}
	var lists []*user.DoctorList
	for _, doctor := range list {
		lists = append(lists, &user.DoctorList{
			TeamId:         int64(doctor.TeamId),
			DoctorName:     doctor.DoctorName,
			DoctorSGinNum:  int64(doctor.DoctorSGinNum),
			DoctorPosition: doctor.DoctorPosition,
		})
	}
	return &user.DoctorListResp{List: lists}, nil
}

func DoctorSow(req *user.DoctorShowReq) (*user.DoctorShowResp, error) {
	show, err := mysql.DockerShow(int(req.Id))
	if err != nil {
		return nil, errors.New("查询失败")
	}
	return &user.DoctorShowResp{
		TeamId:         int64(show.TeamId),
		DoctorName:     show.DoctorName,
		DoctorSGinNum:  int64(show.DoctorSGinNum),
		DoctorPosition: show.DoctorPosition,
	}, nil
}
